<%@ page import="com.entity.Blog" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: Elle
  Date: 2022/6/23
  Time: 9:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>显示所有博客</title>
</head>
<style>
    td,th{
        border: 1px solid ;
        width: 150px;
    }
</style>
<body>
<%
    List<Blog> list = (List<Blog>) request.getAttribute("list");
%>

博客总数：<%=list.size() %>
<table>
    <tr>
        <th>序号</th>
        <th>用户id</th>
        <th>内容</th>
        <th>操作</th>
    </tr>
    <%
        for(Blog tmp : list){
    %>
    <tr>
        <td><%=tmp.getId()%></td>
        <td><%=tmp.getUid()%></td>
        <td><%=tmp.getContent()%></td>
        <td>
            <a href="javascript:del(<%=tmp.getId()%>)">删除</a>
        </td>
    </tr>
    <%
        }
    %>
</table>
<script src="js/jquery.js"></script>
<script>

    $(function () {
        $("tr:even").css("background-color","green");
    });

    function del(id) {
        var bool = confirm("您确定删除吗？");
        if(bool){
            //页面跳转
            location.href="BlogDelServlet?id="+id;
        }
    }
</script>
</body>
</html>
